C#_C#执行js动态编译的方法,本文实例讲述了C#执行js动态编
public static function test1(paramr1)
private const string scriptStr = @"package fhs
}
var retString = paramr1+ '是无敌的!';
} null, null, testParams);
using System.CodeDom.Compiler;
{
复制代码 代码如下:
}//动态编译脚本中的内容
}";
private static Type _evaluateType;
{
Assembly assembly = results.CompiledAssembly;
parameters.GenerateInMemory = true;
//编译的参数
public static object JScriptRun(string jsMethodName,object[] testParams)
using System.Linq;
private static readonly CodeDomProvider _provider = new Microsoft.JScript.JScriptCodeProvider();
using System;
_evaluateType = assembly.GetType("fhs.MyJs");
CompilerResults results = _provider.CompileAssemblyFromSource(parameters, scriptStr);
public class JScripta
using System.Threading.Tasks;
return retObj;
{
}
return retString;
using System.Collections.Generic;
{
using System.Reflection;
//执行指定的方法并传参数
public class MyJs
{
namespace webpro
CompilerParameters parameters = new CompilerParameters();
{
object retObj = _evaluateType.InvokeMember(jsMethodName, BindingFlags.InvokeMethod,
}
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jiaob/c/5996.shtml
